/*******************************************************************************
*								MASTER DO-FILE								   *
*   							   2022										   *
********************************************************************************
********************************************************************************
*						  PART 0: SELECT PARTS TO RUN   							   *
********************************************************************************/
	
	* select which parts of this do-file to run (replace 0 with 1 to activate)
	local 	packages			1	// Install packages -- only needs to be ran once in each computer
	local 	regressions			1 	// Run regressions and export results

	
		
	
********************************************************************************
*			PART 1:  Set standard settings and install packages				   *
********************************************************************************/
set matsize 11000	
	* Install packages
	if `packages' 	{
		ssc install ivreg2
		net install dm88_1, from(http://www.stata-journal.com/software/sj5-4) // renvars
		ssc install coefplot
		ssc install ietoolkit, 	replace
		ssc install estout, 	replace
		ssc install reghdfe
		ssc install xtpqml
		ssc install erepost
		net install sg97_5, from(http://www.stata-journal.com/software/sj12-4) // frmttable (does not work to install like that)
		net install st0043_2, from (http://www.stata-journal.com/software/sj10-4) // eclplot, parmby
	}
	
	ieboilstart, version(14.2) 
	`r(version)'
	

	* Set globals

	
	
		
********************************************************************************
*				PART 2:  Prepare globals and define paths					   *
********************************************************************************	 NOTE: PLEASE USE '/' INSTEAD OF '\' FOR DIRECTORIES FOR COMPATABILITY WITH MACS


	* Set directories 
	* ---------------	
	* Enter path of 
		global root				"../Replication_Files"

	
 	* Subfolder globals
	* -----------------
	global dofiles				"$root/do-files" 
	global data					"$root/Data"
	global results 				"$root/Results"
	global tables				"$root/Results/tables"	
	global graphs				"$root/Results/graphs"




	
		
********************************************************************************
*						PART 3:  Run selected sections						   *
********************************************************************************
capture mkdir "$graphs/Precision"
capture mkdir "$graphs/fsl1o"
capture mkdir "$graphs/trends"
* ------------------------------------------------------------------------------
* 							Analysis
* ------------------------------------------------------------------------------
*
* 	OUTLINE:		Merges all PSML rounds			
* 	REQUIRES:		"$pslm/PSLM 04-05/Data in stata/sec-g.dta"
*					all other PSLM rounds
* 	CREATES:		$analysis_dt/01_psml_water.dta
*
* 
	if `regressions'	do "$dofiles/6_analysis_ADM1.do"
	if `regressions'	do "$dofiles/6_analysis_IVRobustness.do"
	
		
	
	

	
